<?php

use yii\db\Migration;

class m180123_092734_alter_orders extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%orders}}', 'type_id', $this->smallInteger(3)->defaultValue(1)->comment('类型（1课程 2 乐器 3 舞台 4文化 5 组合 6 水吧）'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%orders}}', 'type_id');
        }
    }
}
